﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Text;
using System.Threading.Tasks;
using Windows.Foundation.Metadata;

namespace webRuntimeComponent
{
  public  sealed class TextChangeEventArgs : Object
    {
        private string message;
        public TextChangeEventArgs(string message)
        {
            this.message = message;
        }
        public string Message
        {
            get { return message; }
        }
    }
    //KeyHandler.cs

    [AllowForWeb]
    public sealed class KeyHandler
    {
      
        //public delegate void EventHandler<String>(String str);
        //public event EventHandler<String> DoWork;
        public void setKeyCombination(string URL)
        {
            Debug.WriteLine(URL);
            //if(DoWork!=null)
            //{
            //    DoWork(URL);
            //}
          OnNumberChanged(URL);
        }
        private EventRegistrationTokenTable<EventHandler<TextChangeEventArgs>>
    m_NumberChangedTokenTable = null;

        public event EventHandler<TextChangeEventArgs> NumberChanged
        {
            add
            {
                return EventRegistrationTokenTable<EventHandler<TextChangeEventArgs>>
                    .GetOrCreateEventRegistrationTokenTable(ref m_NumberChangedTokenTable)
                    .AddEventHandler(value);
            }
            remove
            {
                EventRegistrationTokenTable<EventHandler<TextChangeEventArgs>>
                    .GetOrCreateEventRegistrationTokenTable(ref m_NumberChangedTokenTable)
                    .RemoveEventHandler(value);
            }
        }

        public void OnNumberChanged(string newValue)
        {
            EventHandler<TextChangeEventArgs> temp =
                EventRegistrationTokenTable<EventHandler<TextChangeEventArgs>>
                .GetOrCreateEventRegistrationTokenTable(ref m_NumberChangedTokenTable)
                .InvocationList;
            if (temp != null)
            {
                temp(this, new TextChangeEventArgs(newValue));
            }
        }

    }
}
